<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of mdnprob</title>
  <meta name="keywords" content="mdnprob">
  <meta name="description" content="MDNPROB Computes the data probability likelihood for an MDN mixture structure.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">netlab</a> &gt; mdnprob.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../menu.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\netlab&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>mdnprob
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>MDNPROB Computes the data probability likelihood for an MDN mixture structure.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [prob,a] = mdnprob(mixparams, t) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">MDNPROB Computes the data probability likelihood for an MDN mixture structure.

    Description
    PROB = MDNPROB(MIXPARAMS, T) computes the probability P(T) of each
    data vector in T under the Gaussian mixture model represented by the
    corresponding entries in MIXPARAMS. Each row of T represents a single
    vector.

    [PROB, A] = MDNPROB(MIXPARAMS, T) also computes the activations A
    (i.e. the probability P(T|J) of the data conditioned on each
    component density) for a Gaussian mixture model.

    See also
    <a href="mdnerr.html" class="code" title="function e = mdnerr(net, x, t)">MDNERR</a>, <a href="mdnpost.html" class="code" title="function [post, a] = mdnpost(mixparams, t)">MDNPOST</a></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="consist.html" class="code" title="function errstring = consist(model, type, inputs, outputs)">consist</a>	CONSIST Check that arguments are consistent.</li><li><a href="dist2.html" class="code" title="function n2 = dist2(x, c)">dist2</a>	DIST2	Calculates squared distance between two sets of points.</li><li><a href="mdndist2.html" class="code" title="function n2 = mdndist2(mixparams, t)">mdndist2</a>	MDNDIST2 Calculates squared distance between centres of Gaussian kernels and data</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="mdnerr.html" class="code" title="function e = mdnerr(net, x, t)">mdnerr</a>	MDNERR	Evaluate error function for Mixture Density Network.</li><li><a href="mdnpost.html" class="code" title="function [post, a] = mdnpost(mixparams, t)">mdnpost</a>	MDNPOST Computes the posterior probability for each MDN mixture component.</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [prob,a] = mdnprob(mixparams, t)</a>
0002 <span class="comment">%MDNPROB Computes the data probability likelihood for an MDN mixture structure.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">%    Description</span>
0005 <span class="comment">%    PROB = MDNPROB(MIXPARAMS, T) computes the probability P(T) of each</span>
0006 <span class="comment">%    data vector in T under the Gaussian mixture model represented by the</span>
0007 <span class="comment">%    corresponding entries in MIXPARAMS. Each row of T represents a single</span>
0008 <span class="comment">%    vector.</span>
0009 <span class="comment">%</span>
0010 <span class="comment">%    [PROB, A] = MDNPROB(MIXPARAMS, T) also computes the activations A</span>
0011 <span class="comment">%    (i.e. the probability P(T|J) of the data conditioned on each</span>
0012 <span class="comment">%    component density) for a Gaussian mixture model.</span>
0013 <span class="comment">%</span>
0014 <span class="comment">%    See also</span>
0015 <span class="comment">%    MDNERR, MDNPOST</span>
0016 <span class="comment">%</span>
0017 
0018 <span class="comment">%    Copyright (c) Ian T Nabney (1996-2001)</span>
0019 <span class="comment">%    David J Evans (1998)</span>
0020 
0021 <span class="comment">% Check arguments for consistency</span>
0022 errstring = <a href="consist.html" class="code" title="function errstring = consist(model, type, inputs, outputs)">consist</a>(mixparams, <span class="string">'mdnmixes'</span>);
0023 <span class="keyword">if</span> ~isempty(errstring)
0024   error(errstring);
0025 <span class="keyword">end</span>
0026 
0027 ntarget    = size(t, 1);
0028 <span class="keyword">if</span> ntarget ~= size(mixparams.centres, 1)
0029   error(<span class="string">'Number of targets does not match number of mixtures'</span>)
0030 <span class="keyword">end</span>
0031 <span class="keyword">if</span> size(t, 2) ~= mixparams.dim_target
0032   error(<span class="string">'Target dimension does not match mixture dimension'</span>)
0033 <span class="keyword">end</span>
0034 
0035 dim_target = mixparams.dim_target;
0036 ntarget    = size(t, 1);
0037 
0038 <span class="comment">% Calculate squared norm matrix, of dimension (ndata, ncentres)</span>
0039 <span class="comment">% vector (ntarget * ncentres)</span>
0040 <a href="dist2.html" class="code" title="function n2 = dist2(x, c)">dist2</a> = <a href="mdndist2.html" class="code" title="function n2 = mdndist2(mixparams, t)">mdndist2</a>(mixparams, t);
0041 
0042 <span class="comment">% Calculate variance factors</span>
0043 variance = 2.*mixparams.covars;
0044 
0045 <span class="comment">% Compute the normalisation term</span>
0046 normal  = ((2.*pi).*mixparams.covars).^(dim_target./2);
0047 
0048 <span class="comment">% Now compute the activations</span>
0049 a = exp(-(dist2./variance))./normal;
0050 
0051 <span class="comment">% Accumulate negative log likelihood of targets</span>
0052 prob = mixparams.mixcoeffs.*a;</pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>